package com.ynny.date01;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class DateDemo01 {
    public static void main(String[] args) {

        //JDK8版本之前
        Date date = new Date();
        System.out.println(date);

        //JDK8版本之后
        //本地时间
        LocalDateTime time = LocalDateTime.now();
        System.out.println(time);

        LocalDate date2 = LocalDate.now();
        System.out.println(date2);

        LocalTime now = LocalTime.now();
        System.out.println(now);

        //日期格式化
        //yyyy year 年
        //MM month 月
        //dd day  日
        //HH hour 时
        //mm minute 分
        //ss seconds 秒
        DateTimeFormatter dateTimeFormatter =
                DateTimeFormatter.ofPattern("yyyy年MM月dd天 HH:mm:ss");
        String format = dateTimeFormatter.format(LocalDateTime.now());
        System.out.println(format);

    }
}
